package com.rbac.common.enums;

import lombok.Getter;

@Getter
public enum BusinessErrorCode {
    
    // 成功
    SUCCESS(200, "操作成功"),
    
    // 客户端错误 4xx
    BAD_REQUEST(400, "请求参数错误"),
    UNAUTHORIZED(401, "未授权访问"),
    FORBIDDEN(403, "权限不足"),
    NOT_FOUND(404, "资源不存在"),
    METHOD_NOT_ALLOWED(405, "请求方法不允许"),
    VALIDATION_ERROR(422, "参数校验失败"),
    
    // 业务错误 5xx
    INTERNAL_SERVER_ERROR(500, "服务器内部错误"),
    SERVICE_UNAVAILABLE(503, "服务暂不可用"),
    
    // 用户相关错误 1xxx
    USER_NOT_FOUND(1001, "用户不存在"),
    USER_ALREADY_EXISTS(1002, "用户已存在"),
    USERNAME_ALREADY_EXISTS(1003, "用户名已存在"),
    EMAIL_ALREADY_EXISTS(1004, "邮箱已被注册"),
    PHONE_ALREADY_EXISTS(1005, "手机号已被注册"),
    PASSWORD_MISMATCH(1006, "两次输入的密码不一致"),
    OLD_PASSWORD_INCORRECT(1007, "原密码不正确"),
    USER_DISABLED(1008, "用户已被禁用"),
    USER_LOCKED(1009, "用户已被锁定"),
    
    // 认证相关错误 2xxx
    LOGIN_FAILED(2001, "用户名或密码错误"),
    TOKEN_EXPIRED(2002, "登录已过期，请重新登录"),
    TOKEN_INVALID(2003, "无效的访问令牌"),
    LOGOUT_FAILED(2004, "退出登录失败"),
    
    // 权限相关错误 3xxx
    PERMISSION_DENIED(3001, "权限不足"),
    ROLE_NOT_FOUND(3002, "角色不存在"),
    PERMISSION_NOT_FOUND(3003, "权限不存在"),
    ROLE_ALREADY_EXISTS(3004, "角色已存在"),
    ROLE_IN_USE(3005, "角色正在使用中，无法删除"),
    
    // 菜单相关错误 4xxx
    MENU_NOT_FOUND(4001, "菜单不存在"),
    MENU_ALREADY_EXISTS(4002, "菜单已存在"),
    MENU_HAS_CHILDREN(4003, "菜单存在子菜单，无法删除"),
    PARENT_MENU_NOT_FOUND(4004, "父级菜单不存在"),
    
    // 文件相关错误 5xxx
    FILE_UPLOAD_FAILED(5001, "文件上传失败"),
    FILE_NOT_FOUND(5002, "文件不存在"),
    FILE_TYPE_NOT_SUPPORTED(5003, "不支持的文件类型"),
    FILE_SIZE_EXCEEDED(5004, "文件大小超出限制");
    
    private final int code;
    private final String message;
    
    BusinessErrorCode(int code, String message) {
        this.code = code;
        this.message = message;
    }
}